package 地区数据;

import Moudle.*;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class test_parse_excel {
    static String parseData(String jsonStr, City city, List<test_class> excel_list, List<String> zb_list) {
        /*
         * 解析表格数据 json转换为Excel_class
         * 返回值为 注：  的信息*/
        try {

        }catch (Exception e){

        }
        JSONObject return_data = JSONObject.parseObject(jsonStr).getJSONObject("returndata");

        //时间
        JSONArray timeArray = return_data.getJSONArray("wdnodes").getJSONObject(2).getJSONArray("nodes");
        //指标
        JSONArray zbArray = return_data.getJSONArray("wdnodes").getJSONObject(0).getJSONArray("nodes");
        //数据
        JSONArray dataArray = return_data.getJSONArray("datanodes");

        //data 解析  组成map
        Map<String, DataNode> dataNodeMap = new HashMap<>();
        int datanodes_len = dataArray.size();
        for (int i = 0; i < datanodes_len; i++){
            JSONObject jsonObject = dataArray.getJSONObject(i);
            DataNode dataNode = new DataNode(jsonObject.getString("code"),
                    jsonObject.getJSONObject("data").getString("hasdata"),
                    jsonObject.getJSONObject("data").getString("data"));
            dataNodeMap.put(dataNode.code, dataNode);
        }

        //指标 解析
        int zbArray_len = zbArray.size();
        ZB_Class[] zb_classes = new ZB_Class[zbArray_len];
        for (int i = 0; i < zbArray_len; i++) {
            JSONObject jsonObject = zbArray.getJSONObject(i);
            ZB_Class zb = new ZB_Class(jsonObject.getString("name"),
                    jsonObject.getString("code"),
                    jsonObject.getString("memo"),
                    jsonObject.getString("unit"));


            zb_classes[i] = zb;
            excel_list.add(new test_class(zb.cname, zb.unit));
        }

        return new String();
    }
}
